package com.lxq.test2012.main03;


import java.util.Scanner;

class Create{
    String address;//地址
    int size;//配额

    public Create(String addressTag,int sizeTag){
        this.address = addressTag;
        this.size = sizeTag;
    }
    public boolean create(){
        //命令格式检查
        if(!address.matches("([/][a-zA-Z0-9]+)+")) return false; //地址格式错误
        if (size<=0) return false;//配额不是正整数

        //目录地址存在

        return true;
    }
    public void test(){
        System.out.println("create "+address+" "+size);
    }
}

class Remove{
    String address;//地址

    public Remove(String addressTag) {
        this.address = addressTag;
    }

    public boolean remove(){
        //命令格式检查
        if(!address.matches("([/][a-zA-Z0-9]+)+")) return false; //地址格式错误

        return true;
    }
    public void test(){

    }
}

class Set{
    String address;//地址
    int ContentSize;//目录配额
    int ChildSize; //后代配额

    public Set(String addressTag, int contentSizeTag, int childSizeTag) {
        this.address = addressTag;
        this.ContentSize = contentSizeTag;
        this.ChildSize = childSizeTag;
    }

    public boolean set(){
        //命令格式检查
        if(!address.matches("([/][a-zA-Z0-9]+)+")&&!address.equals("/")) return false; //地址格式错误
        if (ContentSize<0||ChildSize<0) return false;//配额不是非负整数

        return true;
    }
    public void test(){

    }
}

public class Main {
    public static void main(String[] args) {
        int n=0;//语句数
        Create create = null;
        Remove remove = null;
        Set set = null;
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();

        for (int i=0;i<n;i++){
            String tag; //接收操作类型
            String addressTag = null;
            int sizeTag01 = 0;
            int sizeTag02 = 0;

            tag = sc.next();

            if(tag.equals("C")){
                addressTag = sc.next();
                sizeTag01 = sc.nextInt();
                create = new Create(addressTag,sizeTag01);

                if (create.create()) System.out.println("Y");
                else System.out.println("N");
//                create.test();
            }
            if(tag.equals("R")){

                addressTag = sc.next();
                remove = new Remove(addressTag);

                if (remove.remove()) System.out.println("Y");
                else System.out.println("N");
            }
            if(tag.equals("Q")){
                addressTag = sc.next();
                sizeTag01 = sc.nextInt();
                sizeTag02 = sc.nextInt();
                set = new Set(addressTag,sizeTag01,sizeTag02);

                if (set.set()) System.out.println("Y");
                else System.out.println("N");

            }
        }


        sc.close();
    }

}

